<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/16 0016
  Time: 上午 10:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
        <title>Title</title>
        <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
        <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
        <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
        <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
        <style>
            .layui-table-view{
                margin-bottom: 120px;
            }
        </style>
</head>
<body>
<br><br><br>

<div>

    <input type="text" name="name" id="name" placeholder="请输入用户昵称"  id="id"  class="layui-input" value="${name}">

    <button type="button" class="layui-btn" onclick="seachOrder()">搜索</button>
</div>
<div>


    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>



</div>
<script>
    function seachOrder() {
        window.location.href='/shop/settingWithdrawer?id=${shopId}&name='+$("#name").val();
    }
</script>
<div class="layui-form">
    <form class="layui-form" action="">
        <table class="layui-table" >
            <thead>
            <tr>
                <th>昵称</th>
                <th>手机号</th>
                <th>头像</th>
                <th>设置为提现人</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${memberList}" var="rl">
                <tr>
                    <td>${rl.name}</td>
                    <td>${rl.tel}</td>
                    <td><img src="${rl.heardUrl}" ></td>
                    <td><input type="checkbox" id="${rl.id}" name="withdrawer" lay-skin="switch" lay-filter="withdrawer" lay-text="选中|未选中"
                        <c:if test="${rl.withdrawer ==1}">checked</c:if>   ></td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </form>




</div>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        form.on('switch(withdrawer)', function(data){
            console.log(data.elem); //得到checkbox原始DOM对象

            var id=data.elem.id;
            console.log(id);
            console.log(data.elem.checked); //开关是否开启，true或者false
            console.log(data.value); //开关value值，也可以通过data.elem.value得到
            console.log(data.othis); //得到美化后的DOM对象


            $.ajax({
                url:'/shop/saveSettingWithdrawer',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:{
                    memberId:id,
                    checked:data.elem.checked,
                    shopId:'${shopId}'
                },
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){

                },
                success:function(reData){
                    if (""!=reData){
                        layer.alert("保存成功", {icon: 6},function () {
                            // 获得frame索引
                           window.location.reload();
                        });
                    }else {
                        layer.alert("保存失败", {icon: 5});
                    }
                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function(){
                    //console.log('结束')
                }
            });


        });
    });
</script>


</body>
</html>
